<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru" xml:lang="ru"> 
    <head>
	<title>LocalCRM</title>
	<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
	<script src="js/jquery-ui-1.8.4.custom.min.js" type="text/javascript"></script>
	<script src="js/jquery.blockUI.js" type="text/javascript"></script>
	<script src="js/jquery.contextMenu.js" type="text/javascript"></script>
	<script src="js/crm/common.js" type="text/javascript"></script>
	<link href="css/redmond/jquery-ui-1.8.4.custom.css" rel="stylesheet" type="text/css"/>
	<link href="css/jquery.contextMenu.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
	<script type="text/javascript">
	{literal}
	$(document).ready
	(
	    function()
	    {
		$('table#filters')
		    .find('thead')
			.css('cursor','pointer')
			.click
			(
			    function()
			    {
				$(this)
				    .parent()
				    .find('tbody')
					.slideToggle();
			    }
			);
	    }
	);
	{/literal}
	</script>

{* Основное верхнее меню-слайдер *}
{include file="admin/submodules/_menu.html"}

	<form method="get">
	<input type="hidden" name="do" value="filter"/>
	<table cellspacing="0" class="ui-widget ui-state-default" id="filters">
	    <thead class="ui-widget-header">
		<tr><th colspan="4">Блок фильтров</th></tr>
	    </thead>
	    <tbody class="ui-widget-content" {if $smarty.session.filter.task==''}style="display: none;"{/if}>
		<tr>
		    <td align="right"><strong>Клиент:</strong></td>
		    <td colspan="3"><input type="text" name="customer_name" value="{$smarty.session.filter.task.customer_name|sslash|escape}" style="width: 100%;"/></td>
		</tr>
		<tr>
		    <td align="right"><strong>Постановщик:</strong></td>
		    <td>
			<select name="cm_id">
			    <option value="">&mdash;</option>
			{foreach from=$managers item=manager}
			    <option value="{$manager.id}" {if $smarty.session.filter.task.cm_id==$manager.id}selected{/if}>{$manager.manager_name}</option>
			{/foreach}
			</select>
		    </td>
		    <td align="right"><strong>Ответственный:</strong></td>
		    <td>
			<select name="rm_id">
			    <option value="">&mdash;</option>
			{foreach from=$managers item=manager}
			    <option value="{$manager.id}" {if $smarty.session.filter.task.rm_id==$manager.id}selected{/if}>{$manager.manager_name}</option>
			{/foreach}
			</select>
		    </td>
		</tr>
		<tr>
		    <td align="right"><strong>Дата постановки:</strong></td>
		    <td>с <input type="text" name="task_startDate" class="date" value="{$smarty.session.filter.task.task_startDate}"/> по <input type="text" name="task_stopDate" class="date" value="{$smarty.session.filter.task.task_stopDate}"/></td>
		    <td align="right"><strong>Дата начала:</strong></td>
		    <td>с <input type="text" name="start_startDate" class="date" value="{$smarty.session.filter.task.start_startDate}"/> по <input type="text" name="start_stopDate" class="date" value="{$smarty.session.filter.task.start_stopDate}"/></td>
		</tr>
		<tr>
		    <td align="right">Отображать:</td>
		    <td colspan="3">
			<select name="display">
			    <option value="">Все</option>
			    <option value="opened" {if $smarty.session.filter.task.display=='opened'}selected{/if}>Открытые</option>
			    <option value="closed" {if $smarty.session.filter.task.display=='closed'}selected{/if}>Закрытые</option>
			</select>
		    </td>
		</tr>
		<tr><td colspan="4"><hr/></td></tr>
		<tr>
		    <td colspan="4" align="center">
			<input type="reset" class="button" value="Очистить фильтр"/>
			<input type="submit" class="button" value="Применить фильтр"/>
		    </td>
		</tr>
	    </tbody>
	</table>
	</form>
	<hr/>

{* Подключаем функционал для работы с задачами *}
{include file="admin/submodules/task.dialog.html"}

	<table width="100%" class="ui-widget" cellspacing="0" rules="all">
	    <thead class="ui-widget-header">
		<tr>
		    <th rowspan="2">#</th>
		    <th rowspan="2">Номер задачи</th>
		    <th rowspan="2">Клиент</th>
		    <th rowspan="2">Суть задачи</th>
		    <th colspan="2">Дата</th>
		</tr>
		<tr>
		    <th>постановки</th>
		    <th>начала выполнения</th>
		</tr>
	    </thead>
	    <tbody class="ui-widget-content">
	    {foreach from=$tasks item=task name=tasks}
		<tr {if $smarty.foreach.tasks.iteration is even}bgcolor="#f0f0ff"{/if} class="task-row ui-state-default {if $task.close==1}ui-state-disabled{elseif $task.task_time|date_format:'%s'<$smarty.now|date_format:'%s'}ui-state-error{/if}">
		    <td align="right" style="padding-right: 1em;">{$smarty.foreach.tasks.iteration}</td>
		    <td align="center"><a href="task.php?id={$task.id}">{$task.id}</a></td>
		    <td><a href="customer-view.php?id={$task.customer_id}">{$task.customer_name|sslash}</a></td>
		    <td style="max-width: 200px;">{$task.note|escape:'quotes'}</td>
		    <td align="center">{if $task.date_time>0}{$task.date_time|date_format:'%d.%m.%Y, %H:%M'}{else}&mdash;{/if}</td>
		    <td align="center">{if $task.task_time>0}{$task.task_time|date_format:'%d.%m.%Y, %H:%M'}{else}&mdash;{/if}</td>
		</tr>
	    {foreachelse}
		<tr><td align="center" colspan="6"><i>задач не найдено</i></td></tr>
	    {/foreach}
	    </tbody>
	</table>
    </body>
</html>
